package com.qiche.controller.mgr;

import com.qiche.aspect.Result;
import com.qiche.dto.SubscribeProductDto;
import com.qiche.enums.ResultEnum;
import com.qiche.model.SubscribeProduct;
import com.qiche.service.SubscribeProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 预约服务 控制器
 * @author chendezhi
 * @date 2018/3/12 11:00
 */
@RestController
@RequestMapping("/subproduct")
public class SubscribeProductController {

	@Autowired
	private SubscribeProductService subscribeProductService;

	/**
	 * 添加预约服务
	 * @param subscribeProduct
	 * @return
	 */
	@PostMapping("/add")
	public Result addProductOfSubscribe(@RequestBody SubscribeProduct subscribeProduct) {
		return subscribeProductService.addProduct(subscribeProduct);
	}

	/**
	 * 删除预约服务
	 * @param subscribeProduct
	 * @return
	 */
	@PostMapping("/delete")
	public Result delProductOfSubscribe(@RequestBody SubscribeProduct subscribeProduct) {
		return subscribeProductService.delProduct(subscribeProduct);
	}

	/**
	 * 根据ID获取预约服务列表
	 * @param subscribeId
	 * @return
	 */
	@GetMapping("/{subscribeId}")
	public Result getProductsBySubscribe(@PathVariable Long subscribeId) {
		List<SubscribeProductDto> productsBySubscribe = subscribeProductService.getProductsBySubscribe(subscribeId);
		return Result.createByResultEnum(ResultEnum.SUCCESS, productsBySubscribe);
	}

}
